/*
 * Copyright 2016-2036 the original author or authors.
 * 
 * COMMERCIAL USE OF THIS SOFTWARE WITHOUT WARRANTY IS NOT ALLOWED.
 * Use is subject to license terms! You can distribute a copy of this software
 * to others for free. This software is a non-profit and open-source project.
 * Any contribution to this project will make it better.
 * All rights reserved! Owned by Stephen Liu.
 * 
 */
package com.github.arrow.function.v6;


import com.github.arrow.function.Coords;
import com.github.arrow.function.RxGeoApi;
import com.github.arrow.function.RxGeoApi.LocationCallback;
import com.github.arrow.function.RxGeoApi.SubmitCallback;

/**
 * @author ste7en.liu@gmail.com
 * @since 2016/10/18
 */
public class ApiWrapper {


    private RxGeoApi rxGeoApi;

    public AsynJob<Coords> getLocation(final String address) {
        return callback ->
            rxGeoApi.getCoords(address, new LocationCallback() {
                @Override
                public void onLocationReceived(Coords coords) {
                    callback.onResult(coords);
                }

                @Override
                public void onError() {
                    callback.onError();
                }
            });
    }

    public AsynJob<Void> submitLocation(final Coords coords) {
        return callback ->
            rxGeoApi.submitCoords(coords, new SubmitCallback() {
                @Override
                public void onSubmitReceived() {
                    callback.onResult(null);
                }

                @Override
                public void onError() {
                    callback.onError();
                }
            });
    }

}
